<?
require("config.php");

$location_status .= "| Edit";
$show_backnav = "presscoverage_menu";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){

	$Date = "$Year-$Month-$Day";

	if ($Picture_name=="" || $Picture_name==NULL) $Picture_name=$old_Picture;

	if ($remove_Picture=="ture") $Picture_name=NULL;

   $field = array(
	"date", 
	"subject", 
	"details",
	"picture",
    "publish",
	"settime",
	"online_date",
	"offline_date",
	);


   $content = array(
	$Date,
	$Subject,
	$Details,
	$Picture_name,
	$Publish,
	$Settime,
	$Online,
	$Offline,
	);

	$exp = "id=$id";

   myUpdate($table,$field,$content,$exp);

	$dir = "med_coverage/";

	myUpload($Picture,$Picture_name,$dir);


   header("location:" . $rela_path . "share/msg.php?v=41");

   exit();

}else{

  if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");

	exit();
  
  }

}


$Query = "SELECT 
code,
date,
subject, 
details,
picture,
publish,
settime,
online_date,
offline_date 
FROM $table WHERE id=$id LIMIT 1";

$r=myQuery($Query);

$Code=$r[0][0];
$Date=$r[0][1];
$Subject=$r[0][2];
$Details=$r[0][3];
$Picture=$r[0][4];
$Publish=$r[0][5];
$Settime=$r[0][6];
$Online=$r[0][7];
$Offline=$r[0][8];

require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="edit">
<input name="id" type="hidden" value="<?print($id)?>">
<input name="old_Picture" type="hidden" value="<?print($Picture)?>">




<table width="95%" border="0" align="center">
  <tr> 
    <td valign="top"> <table border="0" cellspacing="5" cellpadding="1">
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code : </td>
            <td><?print($Code)?></td>
          </tr>
          <tr> 
            <td class="tdheader">Date :</td>
            <td><?print(FFPdate($Date))?></td>
          </tr>
          <tr> 
            <td class="tdheader">Subject :</td>
            <td><input type="text" class="text" name="Subject" size="56" value="<?print($Subject)?>"></td>
          </tr>
          <tr> 
            <td class="tdheader">Details : </td>
            <td><textarea class="text" name="Details" cols="55" rows="20"><?print($Details)?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Picture :</td>
            <td><?loadImage($Picture,$rela_path . $PIC_DIR. $table . "/")?>
			<?removeImage($Picture,"remove_Picture")?>
			<input type="file" class="text" name="Picture" size="45"> </td>
          </tr>
          <tr> 
            <td class="tdheader">Publish :</td>
            <td> 
              <?if ($Publish=="yes") {?>
              <input type="radio" name="Publish" value="yes" checked>
              yes 
              <input type="radio" name="Publish" value="no">
              no 
              <?}else{?>
              <input type="radio" name="Publish" value="yes">
              yes 
              <input type="radio" name="Publish" value="no" checked>
              no 
              <?}?>
            </td>
          </tr>
          <tr>
            <td valign="top" class="tdheader">Settime :</td>
            <td><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
                <tr> 
                  <td height="68" bgcolor="#F5F8FD"><table border="0" cellspacing="5" cellpadding="1">
                      <tr> 
                        <td>
						<?if ($Settime=="y") $active="CHECKED";?>
						
						<input type="checkbox" name="Settime" value="y" <?print($active)?>> <strong>Active</strong></td>
                      </tr>
                      <tr> 
                        <td>Online Date: 
                          <input type="text" name="Online" class="text" value="<?print($Online)?>"></td>
                      </tr>
                      <tr> 
                        <td>Offline Date: 
                          <input type="text" name="Offline" class="text" value="<?print($Offline)?>"></td>
                      </tr>
                    </table></td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('presscoverage_menu.php',1);return false;"> <input type="image" src="../../images/bt_save.gif">
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
    </td>

  </tr>
</table>
<br>
<br>
<br>


</form>

<?
require($rela_path . "inc/footer.php");
?>
